package miblab.school;

import miblab.school.background.GPSCollector;
import miblab.school.lists.FileList;
import miblab.school.lists.FileListMaps;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.PowerManager;
import android.view.View;
import android.widget.Button;

public class ScreenSchoolActivity extends Activity {
	/** Called when the activity is first created. */
	
	private PowerManager.WakeLock wl;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.scr1);
		startService(new Intent(GPSCollector.class.getName()));

		Button viewresults = (Button) findViewById(R.id.button2);
		Button setloc = (Button) findViewById(R.id.button1);
		Button exit = (Button) findViewById(R.id.button3);
		Button mapping = (Button) findViewById(R.id.button4);


		PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
		wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
		wl.acquire();
		   
		//----------------------------------------------------------------------------
		viewresults.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				Intent intent = new Intent(ScreenSchoolActivity.this,FileList.class);
				startActivity(intent);

			}
		} );
		//----------------------------------------------------------------------------		
		setloc.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				Intent intent = new Intent(ScreenSchoolActivity.this,Password.class);
				startActivity(intent);

			}
		} );
		//----------------------------------------------------------------------------
		mapping.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				Intent intent = new Intent(ScreenSchoolActivity.this,FileListMaps.class);
				startActivity(intent);

			}
		} );
		//----------------------------------------------------------------------------
		exit.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				Intent intent = new Intent(Intent.ACTION_MAIN);
				intent.addCategory(Intent.CATEGORY_HOME);
				intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				startActivity(intent);

			}
		} );
		//----------------------------------------------------------------------------
	}

	@Override
	protected void onPause() {
		super.onPause();
		wl.release();
		finish();
	}

}